//
//  HomeMsgListCell.m
//  Dvjf_ios
//
//  Created by Ji on 2018/9/11.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "ozWbrEJLCFHomeMsgListCelluoRRlA.h"

@interface HomeMsgListCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *hnRcVmtimeLabelncDSPi;
@property (nonatomic, strong) UILabel *NdgzxmdesLabelTTSqri;

@end

@implementation HomeMsgListCell

- (void)reloadData
{
    
    self.backgroundColor = QTZ_White;
    if (!self.titleLabel) {
        self.titleLabel = [UILabel new];
        self.titleLabel.font = FONT(15);
        self.titleLabel.textColor = QTZ_Gray51;
        [self addSubview:self.titleLabel];
    }
    
    if (self.titleLabel) {
        self.titleLabel.text = self.data.topic;
        [self.titleLabel sizeToFit];
        self.titleLabel.left = 10;
        self.titleLabel.top = 10;
    }
    
    if (!self.hnRcVmtimeLabelncDSPi) {
        self.hnRcVmtimeLabelncDSPi = [UILabel new];
        self.hnRcVmtimeLabelncDSPi.font = FONT(9);
        self.hnRcVmtimeLabelncDSPi.textColor = QTZ_Gray51;
        [self addSubview:self.hnRcVmtimeLabelncDSPi];
    }
    
    if (self.hnRcVmtimeLabelncDSPi) {
        self.hnRcVmtimeLabelncDSPi.text = [NSString stringWithDate:self.data.addtime];
        [self.hnRcVmtimeLabelncDSPi sizeToFit];
        self.hnRcVmtimeLabelncDSPi.right = FULL_WIDTH - 10;
        self.hnRcVmtimeLabelncDSPi.top = 10;
    }
    
    if (!self.NdgzxmdesLabelTTSqri) {
        self.NdgzxmdesLabelTTSqri = [UILabel new];
        self.NdgzxmdesLabelTTSqri.numberOfLines = 0;
        [self addSubview:self.NdgzxmdesLabelTTSqri];
    }
    
    if (self.NdgzxmdesLabelTTSqri) {
        
        NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:self.data.msg];
        [attributeStr addAttribute:NSFontAttributeName value:FONT(12) range:NSMakeRange(0, attributeStr.length)];
        [attributeStr addAttribute:NSForegroundColorAttributeName value:QTZ_Gray102 range:NSMakeRange(0, attributeStr.length)];
        NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc]init];
        [paragraph setLineSpacing:12];//设置行间距
        [paragraph setAlignment:NSTextAlignmentLeft];//设置对齐方式
        [paragraph setBaseWritingDirection:NSWritingDirectionLeftToRight];//设置书写方向
        [attributeStr addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, attributeStr.length)];
        self.NdgzxmdesLabelTTSqri.attributedText = attributeStr;
        self.NdgzxmdesLabelTTSqri.width = FULL_WIDTH - 20;
        [self.NdgzxmdesLabelTTSqri sizeToFit];
        self.NdgzxmdesLabelTTSqri.top = 43;
        self.NdgzxmdesLabelTTSqri.left = 10;
    }
    
}

+ (CGFloat)heightForCellWithDes:(NSString *)des
{
    if (!des) return 0;
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc]init];
    [paragraph setLineSpacing:12];//设置行间距
    [paragraph setAlignment:NSTextAlignmentLeft];//设置对齐方式
    NSDictionary *attribute = @{NSFontAttributeName : FONT(12), NSParagraphStyleAttributeName : paragraph};
    CGSize size = [des sizeWithUIAttribute:attribute forWidth:FULL_WIDTH - 20];
    
    return size.height + 58;//上下留白
    
    
}

@end
